﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TeamFile.aspx.cs" Inherits="OnlineCooperation.TeamFileTree" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>TeamFileTree</title>
    <script src="js/jquery.js"></script>
    <script src="js/jquery.easing.min.js"></script>
    <script src="js/bootstrap-transition.js"></script>
    <script src="js/bootstrap-alert.js"></script>
    <script src="js/bootstrap-modal.js"></script>
    <script src="js/bootstrap-dropdown.js"></script>
    <script src="js/bootstrap-scrollspy.js"></script>
    <script src="js/bootstrap-tab.js"></script>
    <script src="js/bootstrap-tooltip.js"></script>
    <script src="js/bootstrap-popover.js"></script>
    <script src="js/bootstrap-button.js"></script>
    <script src="js/bootstrap-collapse.js"></script>
    <script src="js/bootstrap-carousel.js"></script>
    <script src="js/bootstrap-typeahead.js"></script>
    <script src="js/html5shiv.js"></script>
    <script src="js/jqueryFileTree/jqueryFileTree.js"></script>

    <link href="js/jqueryFileTree/jqueryFileTree.css" rel="stylesheet" />
    <link href="css/bootstrap.css" rel="stylesheet" />
    <link href="css/bootstrap-responsive.css" rel="stylesheet" />
    <link href="css/s.css" rel="stylesheet" />
    <link href="css/FamilyTree.css" rel="stylesheet" />

    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" href="ico/apple-tsouch-icon-57-precomposed.png" />
    <link rel="shortcut icon" href="ico/favicon.png" />

    <style type="text/css">
        body {
            padding-top: 20px;
            padding-bottom: 60px;
            background: url(img/brickwall.png) repeat 0 0;
        }

        /* Custom container */
        .container-narrow {
            margin: 0 auto;
            max-width: 1200px;
        }

            .container-narrow > hr {
                margin: 30px 0;
            }

        .FileBlock {
            width: inherit;
            height: auto;
            border: 1px solid #000000;             
        }
        .file-logo {
            width:16px;
            height:16px;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {

            var path;
            getdata();  //通过同步ajax为 path 赋值

            $('#FolderTree').fileTree({
                root: path,
                script: 'TeamFileTreeCon.aspx',
                folderEvent: 'click',
                expandSpeed: 750,
                collapseSpeed: 750,
                expandEasing: 'easeOutBounce',
                collapseEasing: 'easeOutBounce'
            }, function (file) {
                alert(file);
            });



            function getdata() {
                $.ajax({
                    type: "POST",
                    url: "TeamFileHd.ashx", //获取服务器路径
                    data: "action=root",
                    async: false, //必须设为同步才能得到正确的值 ！！！
                    success: function (data) {
                        path = data;
                    }

                })
            }
        });


        function BtnDel_onclick() {
            var x = window.confirm('确认删除吗？');
            if (x == "")
                return;
            var ul = document.getElementById("DocList");
            var childs = ul.childNodes;
            for (var i = childs.length - 1; i >= 0; i--) {
                if (childs[i].childNodes[0].checked == true)
                    $.ajax({
                        type: "POST",
                        url: "TeamFileDelFile.ashx", //获取服务器路径
                        data: "FileName=" + childs[i].childNodes[1].innerHTML,
                        async: false, //必须设为同步才能得到正确的值 ！！！
                        success: function (data) {
                            alert("删除成功！");
                        }

                    })
            }
        }

        function BtnDelFolder_onclick() {
            var x = window.confirm('确认删除吗？');
            if (x == "")
                return;
            $.ajax({
                type: "POST",
                url: "TeamFileDelFolder.ashx", //获取服务器路径
                async: false, //必须设为同步才能得到正确的值 ！！！
                success: function (data) {
                    alert("删除成功！");
                }

            })
        }

        function BtnCreateFolder_onclick() {
            var input = window.prompt("请输入您要创建的目录名！例如：在根目录下创建文件夹a，请输入a ;在根目录下的a文件夹中创建b文件夹，请输入a/b……以此类推,输入为空表示取消");
            if (!input) {
                return;
            }
            while (input == "") {
                alert("目录名不能为空！");
                input = window.prompt("请输入您要创建的目录名！例如：在根目录下创建文件夹a，请输入a ;在根目录下的a文件夹中创建b文件夹，请输入a/b……以此类推,输入为空表示取消");
                if (!input)
                    return;
            }
            $.ajax({
                type: "POST",
                url: "TeamFileCreateFolder.ashx", //获取服务器路径
                data: "FolderName=" + input,
                async: false, //必须设为同步才能得到正确的值 ！！！
                success: function (data) {
                    alert(data);
                }

            })
        }
        function BtnDl_onclick() {
            var ul = document.getElementById("DocList");
            var childs = ul.childNodes;
            var flag = 1;
            var curdir = document.getElementById("LabelRealCD").innerHTML;
            for (var i = childs.length - 1; i >= 0; i--) {
                if (childs[i].childNodes[0].checked == true) {
                    var url = curdir + childs[i].childNodes[1].text;
                    if (document.all) {
                        var a = document.createElement("A");
                        a.target = "_blank";
                        a.href = url;
                        document.body.appendChild(a);
                        a.click();
                        setTimeout(function () { a.parentNode.removeChild(a); }, 50);
                    }
                    else window.open(url, "_blank");
                }
            }
        }
    </script>
    <script src="js/jquery.smint.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            $('.subMenu').smint({
                'scrollSpeed': 1000
            });
        });
    </script>
    <script type="text/javascript">
        function Sub() {
            $.ajax({
                type: "POST",
                url: "Logout.ashx", //获取服务器路径\
                async: false, //必须设为同步才能得到正确的值 ！！！
                success: function (data) {
                    window.location.href = "Login.aspx";
                }

            })
        }

    </script>
</head>
<body>
    <form id="FormTeamFile" runat="server">
        <div class="container-narrow">
            <div class="subMenu2">            
            <div class="navbar navbar-static">
                <div class="navbar-inner">
                    <div class="container" style="width: auto;">
                        <a id="sTop" class="brand" href="#"><%=Session["UserName"] %></a>
                        <ul class="nav" role="navigation">
                            <li class="dropdown">
                                <a id="drop1" href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">个人信息</a>
                                <ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
                                    <li role="presentation"><a role="menuitem" tabindex="-1" href="ResetUserInfo.aspx">修改基本信息</a></li>                                  
                                    <li role="presentation" class="divider"></li>
                                    <li role="presentation"><a role="menuitem" tabindex="-1" href="ResetPwd.aspx">修改密码</a></li>
                                </ul>
                            </li>
                            <li><a href="TeamIndex.aspx" id="s1" class="subNavBtn" role="button">团队信息</a></li>
                            <li><a href="PersonalFile.aspx" id="s2" class="subNavBtn" role="button" >个人文件管理</a></li>
                            
                        </ul>
                        <ul class="nav pull-right">
                                <li><a href="HomePageJump.aspx" target="_parent" class="dropdown">返回首页</a></li>
                                
                        </ul>
                    </div>
                </div>
            </div>
            </div>
            <br />
            <hr />
            <div class="container row-fluid">
                <div class="span5">
                    <div class="alert alert-success">
                        当前文件路径:                       
                        <span id="LabelCD" />
                    </div>
                    <img src="js/jqueryFileTree/images/folder_open.png" class="file-logo"/>
                        <asp:Button ID="Button1" class="btn btn-mini" Text="Root" runat="server"/>
                    <div id="FolderTree"></div>
                    <div><span id="LabelRealCD" style="VISIBILITY: hidden" /></div>

                </div>

                <div class="span5">
                    <div class="alert alert-info">当前文件夹下的文件</div>
                    <div>
                        <ul id="DocList" runat="server"></ul>
                    </div>
                </div>
                <div class="span2">
                    <div class="control-group">
                        <div class="controls">
                            <asp:FileUpload ID="FileUpload1" runat="server" />
                        </div>
                        <div class="controls">
                            <asp:Button ID="BtnUpload" runat="server" Text="确认上传" class="btn" OnClick="Button1_Click" />
                        </div>
                        <br />
                        <div class="controls">
                            <button id="BtnCreateFolder" class="btn" onclick="return BtnCreateFolder_onclick()">建立文件夹</button>
                        </div>
                        <br />
                        <div class="controls">
                            <button id="BtnDel" class="btn" onclick="return BtnDel_onclick()">删除文件</button>
                        </div>
                        <br />
                        <div class="controls">
                            <button id="BtnDelFolder" class="btn" onclick="return BtnDelFolder_onclick()">删除文件夹</button>
                        </div>
                        <br />
                        <div class="controls">
                            <button id="BtnDl" class="btn" onclick="return BtnDl_onclick()">下载文件</button>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </form>
</body>
</html>
